﻿using System.Collections.Generic;

namespace Heimdallr.Net
{
    /// <summary>
    /// Represents the module of <see cref="HttpElement"/> which is for handling incoming request and generating notifications.
    /// </summary>
    public interface IHttpRequestModule
    {
        #region Property

        /// <summary>
        /// Gets the HTTP method.
        /// </summary>
        string Method { get; }

        /// <summary>
        /// Gets the relative path.
        /// </summary>
        string RelativePath { get; }

        /// <summary>
        /// Gets the credential type.
        /// </summary>
        HttpModuleCredentialType CredentialType { get; }

        #endregion

        #region Method

        /// <summary>
        /// Indicates if user name and password of incoming request is valid or not.
        /// </summary>
        /// <param name="username">User name of incoming request.</param>
        /// <param name="password">Password of incoming request.</param>
        /// <returns>If valid, the return value is true. Otherwise false.</returns>
        bool Validate(string username, string password);

        /// <summary>
        /// Generates notifications from HTTP incoming request. 
        /// </summary>
        /// <param name="request">An HTTP incoming request passed by <see cref="HttpElement"/>.</param>
        /// <returns>One or several notifications from HTTP incoming request.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="request"/> is null.</exception>
        IEnumerable<Notification> Read(HttpRequestContext request);

        #endregion
    }
}
